{include file="header.html"}
<style>
.gm-span{ display: inline-block;width: 50px;text-align: center;text-align: right;padding-right: 3px;}
.gm-span2{ width: 46px;}
.search > input{ width: 160px;}
.red{ color: red;}
#checkboss{ width: 100%;height: 100%;cursor: pointer;text-align: center;}
.fot{ text-align: center;background: none;}
</style>
<div class="page-header">
	<h6>
		商品列表
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			商品列表
		</small>
		<div>
			<a href="javascript:void(0)" id="changePrice">批量改价格</a>
			<!--<a href="javascript:void(0)" id="changeIntegral">批量改购买积分</a>-->
			<a href="javascript:void(0)" id="changeExtProperty">批量改属性</a>
			<a href="javascript:void(0)" id="changeCate">改变分类</a>
			<!--<a href="javascript:void(0)" id="changeBrand">改变品牌</a>-->
			<a href="?app=goods&act=qrcode_out&id={$id}&keyword={$keyword}&shop_id={$shop_id}" target="_blank">导出二维码</a>
		</div>
	</h6>
</div>

<form class="form-inline" action="?" method="get">
<input type="hidden" name="app" id="app" value="goods" />
<input type="hidden" name="act" id="act" value="index" />
<input type="hidden" name="jiage" id="jiage" value="" />
<input type="text" name="id" id="id" value="{$id}" placeholder="ID" />
<input type="text" name="keyword" id="keyword" value="{$keyword}" placeholder="关键词" />
<div class="checkbox"><label><input type="checkbox" name="ext_property[]" id="ext_property1" value="1" class="ace" {if strpos(','|cat:$ext_property|cat:',', ',1,')!==false}checked{/if} /><span class="lbl">推荐</span></label></div>
<div class="checkbox"><label><input type="checkbox" name="ext_property[]" id="ext_property2" value="2" class="ace" {if strpos(','|cat:$ext_property|cat:',', ',2,')!==false}checked{/if} /><span class="lbl">热销</span></label></div>
<!--<div class="checkbox"><label><input type="checkbox" name="ext_property[]" id="ext_property3" value="3" class="ace" {if strpos(','|cat:$ext_property|cat:',', ',3,')!==false}checked{/if} /><span class="lbl">精品</span></label></div>-->
<div class="checkbox"><label><input type="checkbox" name="ext_property[]" id="ext_property4" value="4" class="ace" {if strpos(','|cat:$ext_property|cat:',', ',4,')!==false}checked{/if} /><span class="lbl">新品</span></label></div>
<div class="checkbox"><label><input type="checkbox" name="ext_property[]" id="ext_property5" value="5" class="ace" {if strpos(','|cat:$ext_property|cat:',', ',5,')!==false}checked{/if} /><span class="lbl">折扣</span></label></div>
<br />
<input type="text" name="startprice" id="startprice" value="{$startprice}" placeholder="价格" />
<span class="gm-span" style="text-align: center">-</span>
<input type="text" name="endprice" id="endprice" value="{$endprice}" />
<span class="gm-span gm-span2"></span>
<!--<select name="shop_id" id="shop_id" class="form-control" data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
	<option value="">门店</option>
	{foreach from=$shops item=g}
	<option value="{$g->id}" {if $g->id == $shop_id}selected{/if}>{$g->name}</option>
	{/foreach}
</select>-->
<select name="cate_id" id="cate" class="form-control" data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
	<option value="">分类</option>
	{$categorys}
</select>
<!--<select name="brand_id" id="brand_id" class="form-control" data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
	<option value="">品牌</option>
	{foreach from=$brand item=g}
	<option value="{$g->id}" {if $g->id == $brand_id}selected{/if}>{$g->name}</option>
	{/foreach}
</select>-->
<button type="submit" class="btn btn-info btn-sm">
	<i class="ace-icon fa fa-search bigger-110"></i>搜索
</button>
</form>

<div class="table-content">
<table id="simple-table" class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th style="padding:0px;"><div id='checkboss'>全选</div></th>
			<th>ID</th>
			<th>图片</th>
			<th>名称</th>
			<th>二维码</th>
			<th>价格</th>
			<th>促销价、特价</th>
			<th>库存</th>
			<th>所属类别</th>
			<!--<th>所属店铺</th>
			<th>所属品牌</th>-->
			<th>状态</th>
			<th>添加时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<form action="?app=goods&act=check_cate" method="post" id="tochange">
		<!--<input type="hidden" name="app" id="app" value="goods" />
		<input type="hidden" name="act" id="act" value="check_cate" />-->
		{foreach from=$rs item=row name=row}
		<tr>
			<td><input type="checkbox" name="checkbox[]" class="goods_id" id="{$row.id}" value="{$row.id}" /></td>
			<td>{$row.id}</td>
			<td><img src="{if $row.pic !== ''}{$row.pic}{else}/images/nopic.png{/if}" width="100" /></td>
			<td><a href="index.php?app=goods&act=edit&id={$row.id}&current_page={$page.current_page}&oldwhere={$oldwhere}">{$row.name|truncate:20}</a></td>
			<td><img src="?app=goods&act=qrcode&url={$row.url}" style="width:130px"></td>
			<td>{$row.price}</td>
			<td>{$row.promote_price}</td>
			<td>{$row.stocks}</td>
			<td>{$row.cname}</td>
			<!--<td>{$row.sname}</td>
			<td>{$row.bname}</td>-->
			<td>{if $row.status == 1}正常{else}下架{/if}</td>
			<td>{$row.add_time|date_format:"%Y-%m-%d"}</td>
			<td>
				<a href="index.php?app=goods&act=edit&id={$row.id}&current_page={$page.current_page}&oldwhere={$oldwhere}">
					<span class="btn btn-xs btn-info">
					<i class="ace-icon fa fa-pencil bigger-120"></i>
				</span>
				</a>
				<a href="index.php?app=goods&act=delete&id={$row.id}&current_page={$page.current_page}&oldwhere={$oldwhere}" class="delete">
					<span class="btn btn-xs btn-danger">
					<i class="ace-icon fa fa-trash-o bigger-120"></i>
				</span>
				</a>
			</td>
		</tr>
		{foreachelse}
		<tr bgcolor="white"><td colspan="13" height="50">暂无记录</td></tr>
		{/foreach}

	</form>
	</tbody>
</table>
</div>

 <!-- 弹出 -->
<div class="modal fade" id="to-changePrice" role="dialog" aria-labelledby="gridSystemModalLabel">
	<div class="modal-dialog row" role="document" style="margin-top:8%;">
		<div class="modal-content col-lg-8 col-lg-offset-2">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
				<div class="modal-body">
					<div class="container-fluid">
						请填写要改成的价格
						<label class="coo-radio"><input type="radio" name="price_type" id="price_type1" class="price_type" value="0" checked /><i></i></label><label for="price_type1">值</label>　
						<label class="coo-radio"><input type="radio" name="price_type" id="price_type2" class="price_type" value="1" /><i></i></label><label for="price_type2">百分比</label>　
						<input type="text" name="price" /><span>元</span>
					</div>
				</div>
				<div class="modal-footer fot">
					<button type="button" class="btn" data-dismiss="modal"> 取消 </button>
					<button type="button" class="btn get-to"> 提交 </button>
				</div>
		</div>
	</div>
</div>

<div class="modal fade" id="to-changeIntegral" role="dialog" aria-labelledby="gridSystemModalLabel">
	<div class="modal-dialog row" role="document" style="margin-top:8%;">
		<div class="modal-content col-lg-8 col-lg-offset-2">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
				<div class="modal-body">
					<div class="container-fluid">
						请填写要改成的购买积分
						<label class="coo-radio"><input type="radio" name="integral_type" id="integral_type1" class="integral_type" value="0" checked /><i></i></label><label for="integral_type1">值</label>　
						<label class="coo-radio"><input type="radio" name="integral_type" id="integral_type2" class="integral_type" value="1" /><i></i></label><label for="integral_type2">百分比</label>　
						<input type="text" name="integral" /><span>积分</span>
					</div>
				</div>
				<div class="modal-footer fot">
					<button type="button" class="btn" data-dismiss="modal"> 取消 </button>
					<button type="button" class="btn get-to"> 提交 </button>
				</div>
		</div>
	</div>
</div>

<div class="modal fade" id="to-changeExtProperty" role="dialog" aria-labelledby="gridSystemModalLabel">
	<div class="modal-dialog row" role="document" style="margin-top:8%;">
		<div class="modal-content col-lg-8 col-lg-offset-2">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
				<div class="modal-body">
					<div class="container-fluid">
						请选择要改成的属性<br />
						<label class="coo-checkbox"><input type="checkbox" name="ext_property[]" id="property2" value="2" /><i><i></i></i></label><label for="property2">热销</label>　
						<label class="coo-checkbox"><input type="checkbox" name="ext_property[]" id="property5" value="5" /><i><i></i></i></label><label for="property5">折扣</label>　
						<label class="coo-checkbox"><input type="checkbox" name="ext_property[]" id="property1" value="1" /><i><i></i></i></label><label for="property1">推荐</label>　
						<label class="coo-checkbox"><input type="checkbox" name="ext_property[]" id="property4" value="4" /><i><i></i></i></label><label for="property4">新品</label>
					</div>
				</div>
				<div class="modal-footer fot">
					<button type="button" class="btn" data-dismiss="modal"> 取消 </button>
					<button type="button" class="btn get-to"> 提交 </button>
				</div>
		</div>
	</div>
</div>

<div class="modal fade" id="to-changeCate" role="dialog" aria-labelledby="gridSystemModalLabel">
	<div class="modal-dialog row" role="document" style="margin-top:8%;">
		<div class="modal-content col-lg-8 col-lg-offset-2">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
				<div class="modal-body">
					<div class="container-fluid">
						请选择要改成的分类
						<select name="catechange" id="cate" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
							<option value=""> 分类 </option>
							{foreach from = $cate_parent item =val}
								<optgroup label="{$val->name}">
									{foreach from = $cate item =row}
										{if $row->parent_id == $val->id}
										<option value="{$row->id}">{$row->name}</option>
										{/if}
									{/foreach}
								</optgroup>
							{/foreach}
						</select>
					</div>
				</div>
				<div class="modal-footer fot">
					<button type="button" class="btn" data-dismiss="modal"> 取消 </button>
					<button type="button" class="btn get-to"> 提交 </button>
				</div>
		</div>
	</div>
</div>

<div class="modal fade" id="to-changeBrand" role="dialog" aria-labelledby="gridSystemModalLabel">
	<div class="modal-dialog row" role="document" style="margin-top:8%;">
		<div class="modal-content col-lg-8 col-lg-offset-2">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
				<div class="modal-body">
					<div class="container-fluid">
						请选择要改成的品牌
						<select name="brandchange" id="cate" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
							<option value=""> 品牌 </option>
							{foreach from = $brand item =row}
							<option value="{$row->id}">{$row->name}</option>
							{/foreach}
						</select>
					</div>
				</div>
				<div class="modal-footer fot">
					<button type="button" class="btn" data-dismiss="modal"> 取消 </button>
					<button type="button" class="btn get-to"> 提交 </button>
				</div>
		</div>
	</div>
</div>
<div class="mypage">
	共 {$page.num_records} 个记录  {$page.current_page} / {$page.num_pages} 页  {$page.first_page} {$page.prev} {$page.nav} {$page.next} {$page.last_page}
</div>

{include file="footer.html"}
<script>
$(function(){
	$('#endprice').blur(function(){
		var a = $(this).val();
		if( a >= 0 && a !== ''){
			$('#jiage').val(1);
		}else{
			$('#jiage').val('');
		}
	});
	$('#checkboss').click(function(){
		if($(this).hasClass('red')){
			$(this).removeClass('red');
			$('.goods_id:checkbox').removeAttr('checked').prop('checked', false);
		}else{
			$(this).addClass('red');
			$('.goods_id:checkbox').attr('checked', 'checked').prop('checked', 'checked');
		}
	});
	$('#changePrice').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#to-changePrice').modal();
    });
	$('.price_type').change(function(){
		var span = $(this).parent().parent().find('span');
		if(Number($(this).val())==0)span.html('元');
		else span.html('%');
	});
	$('#changeIntegral').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#to-changeIntegral').modal();
    });
	$('.integral_type').change(function(){
		var span = $(this).parent().parent().find('span');
		if(Number($(this).val())==0)span.html('积分');
		else span.html('%');
	});
	$('#changeExtProperty').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#to-changeExtProperty').modal();
    });
	$('#changeCate').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#to-changeCate').modal();
    });
	$('#changeBrand').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#to-changeBrand').modal();
    });
    $('.get-to').click(function(){
		var checkbox = $('.goods_id:checked');
		if(!checkbox.length){
			alert('请选择需要修改的商品');
			return;
		}
        $('#tochange').submit();
    });
});
</script>
